$(".submit").click(function(){
    var list=$(".add-list li");
    var goodsHeadImageUrl=list.eq(0).find("input").val();
    var goodsName=list.eq(1).find("input").val();
    var data1=list.eq(2).find("input").val();
    var data2=list.eq(3).find("input").val();
    var data3=list.eq(4).find("input").val();
    var goodsCategory=list.eq(7).find("input").val();
    var goodsDescription=list.eq(6).find("input").val();
    var putawayStatus=list.eq(8).find("input").val();
    var goodsAbstract=list.eq(5).find("input").val();
    var goodsSizeMapPrice=[];
    var goodsDetalImage=[];
    var json;
    if(data2){
        goodsSizeMapPrice.push({"size":"small","price":data1},{"size":"middle","price":data2})
    }
    if(data3){
        goodsSizeMapPrice.push({"size":"big","price":data3},{"size":"small","price":data1});
    }
    for(var i=10;i<$(".add-list li").length;i++){
        goodsDetalImage.push({"detailImgUrl":list.eq(i).find("input").val()})
    }
    check();
    json={"goodsName":goodsName,
        "goodsHeadImageUrl":goodsHeadImageUrl,
        "goodsCategory":goodsCategory,
        "goodsDescription":goodsDescription,
        "putawayStatus":putawayStatus,
        "goodsSizeMapPrice":goodsSizeMapPrice,
        "goodsAbstract":goodsAbstract,
        "goodsDetalImage":goodsDetalImage
    }
    $.ajax({
        url:'/manager/getGoodsInsert',
        data:json,
        dataType:'json',
        type:'post',
        success:function(){
            alert("提交成功");
            $(".add-table").css("display","none");
            $(".shop-list").css("opacity",1);
        },
        error:function(){
            console.log(json);
        }
    })
    function check(){
        if(!goodsHeadImageUrl){
            alert("图片链接不能为空")
        }
        if(!goodsName){
            alert("商品名称不能为空")
        }
        if(!goodsCategory){
            alert("图片简介不能为空")
        }
        if(!putawayStatus){
            alert("商家状态不能为空")
        }
        if(!data1){
            alert("size不能为空");
        }
    }
})
